package com.example.mybatis;

import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Mapper
public interface UserInfoMapper {
    @Results(id="BaseMap",value = {
            @Result(column = "delete_flag",property = "deleteFlag"),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "update_time",property = "updateTime")
    })
    @Select("select * from user_info")
    List<UserInfo> selectAll();

    @ResultMap("BaseMap")
    @Select("select * from user_info where id=#{id}")
    UserInfo selectById1(Integer id);

    @Select("select * from user_info where username=#{username} and password=#{password}")
    List<UserInfo> selectsuch1(String username, String password);

    @Select("select * from user_info where username=#{username} and password=#{password}")
    List<UserInfo> selectsuch2(@Param("username") String userName, @Param("password") String passWord);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into user_info (username ,password,age) values (#{username},#{password},#{age})")
    Integer insertone(UserInfo u);

    @Select("select id,username,password,age,gender,phone,delete_flag as deletFlag,create_time as createTime,update_time asupdateTime from user_info")
    List<UserInfo> selectById3(Integer id);
}
